<?php
require "common.php";
class delZW{
    private $common="";
    private $key_rand=["d1","d2","d3"];
    public function __construct()
    {
        $this->common=new Common();
    }
    public function del($str){
        $d_arr=explode("_",$str);
        $where=[];
        foreach ($d_arr as $k=>$v){
            if (!empty($v)){
                $where["d".$k]=$v;
            }else{
                break;
            }
        }
        $sql=$this->UpdateSqlSplice($where);
        $query=mysqli_query($this->common->startMysql(),$sql);
        if ($query) {
            Common::rs("删除成功");
        }else{
            Common::rf("删除失败");
        }
    }

    public function UpdateSqlSplice($obj){
        $key=array_keys($obj);
        $key_rand=$this->key_rand;
        $sql="UPDATE lunwen_yuanfile set `is_del`='1' WHERE user_info_id='".$_SESSION['id']."' and";
        foreach ($key as $key_v){
            if (in_array($key_v,$key_rand)){
                $sql.=" `$key_v`='".$obj["$key_v"]."' and";
            }
        }
        $sql=mb_substr($sql,0,-3);
        return $sql;
    }
}

if (!empty($_GET['d'])){
    $delZW=new delZW();
    $delZW->del($_GET['d']);
}